package logic

import (
	"context"
	"goods/models/redisinit"

	"goods/goods"
	"goods/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type AmountCartLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAmountCartLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AmountCartLogic {
	return &AmountCartLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *AmountCartLogic) AmountCart(in *goods.AmountCartRequest) (*goods.AmountCartResponse, error) {
	// todo: add your logic here and delete this line
	amount, count := redisinit.CartAmount(in.UsersId)
	return &goods.AmountCartResponse{
		Count:  int64(count),
		Amount: int64(amount),
	}, nil
}
